package com.laibatour.generator.utils;

import org.apache.commons.lang.StringUtils;

/**
 * Created by guan on 2016/2/24.
 */
public class GeneratorUtil {

    /**
     * 首字母大写
     */
    public static String cap(String str) {
        return StringUtils.capitalize(str);
    }

    /**
     * 首字母小写
     */
    public static String uncap(String str) {
        return StringUtils.uncapitalize(str);
    }

    /**
     * 替换字符串并让它的下一个字母为大写
     */
    public static String replace(String str) {
        StringBuilder nStr = new StringBuilder();
        String[] split = str.toLowerCase().replace("_lang", "").split("_");
        for (int i = 0; i < split.length; i++) {
            if (i == 0) {
                nStr.append(split[i]);
            } else {
                nStr.append(StringUtils.capitalize(split[i]));
            }
        }
        return nStr.toString();
    }

    public static String package2path(String packPath) {
        if (packPath == null) {
            return packPath;
        }
        return packPath.replaceAll("\\.", "/");
    }


}
